home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_300
/
348_01
/
z80adoc.mm
< prev
next >
Wrap
Text File
|
1991-04-30
|
34KB
|
1,065 lines
.nr N 4
\" use "tbl -D z80adoc.mm |troff -Tps -mm |eps | lp -dpsript"
\" on altos86 to print
.PF ""
.PH ""
.rs
.sp 5
.ce
\s24 Z80 Cross Assembler\s10
.sp 2
.ce
Portable Version
.sp 20
.AS
This program lets you use your computer to assemble
code for the Intel Z80 family of microprocessors.
The program is written in portable C.
All assembler features are supported except
relocation, linkage, and macros.
.AE
.SK
.nr P 1
.PH ""
.PF "''Page \\\\nP''"
.ce
Z80 Cross-Assembler (Portable)
.ce
Version 0.0
.ce
Copyright (c) 1988 Michael G. Panas
.SA 1
\" Use 3 for troff and 1 for nroff
.ds HF 1 1 1
\".ds HF 3 3 3
.H 1 "Introduction"
.P
This assembler was developed to cross-assemble the Z80 assembly language
mnemonics and pseudo opcodes defined by an assembler already
running on a mini-computer.
As such the mnemonics may look very strange, since they are not
standard Zilog Z80 mnemonics but, extensions to the 8080 language.
Many enhancements to the original mini-computer version have been made.
.P
This package assembles the dialect of Z80 source code
defined in Appendix I into Z80 object code.
It will run under DOS 2.x and up and also several
UNIX machines (see appendix II - portability).
.H 1 "How to Use the Cross-Assembler"
.P
This program requires one input file (your Z80 source code) and
zero to two output files (the listing and the object). The input
file MUST be specified, or the assembler will bomb on a fatal
error. The listing and object files are optional. If no listing
file is specified, no listing is generated, and if no object file
is specified, no object is generated. If the object file is
specified, the object is written to this file in "Intel
hexadecimal" format.
.ti
The command line for the cross-assembler looks like this:
.ti
z80a source_file { -l list_file } { -o object_file }
.ti
where the { } indicates that the specified item is optional.
.DS I
Some examples are in order:
z80a testz80.asm source: testz80.asm
listing: none
object: none
z80a testz80.asm -l testz80.prn source: testz80.asm
listing: testz80.prn
object: none
z80a testz80.asm -o testz80.hex source: testz80.asm
listing: none
object: testz80.hex
z80a testz80.asm -l testz80.prn -o testz80.hex
source: testz80.asm
listing: testz80.prn
object: testz80.hex
.DE
.P
The order in which the source, listing, and object files are
specified does not matter. Note that no default file name extensions
are supplied by the assembler as this gives rise to portability problems.
.H 1 "Format of Cross-Assembler Source Lines"
.P
The source file that the cross-assembler processes into a
listing and an object is an ASCII text file that you can prepare
with whatever editor you have at hand. The most-significant
(parity) bit of each character is cleared as the character is
read from disk by the cross-assembler, so editors that set this
bit (such as WordStar's document mode) should not bother this
program. All printing characters, the ASCII TAB character (09H),
and newline character(s) are processed by the assembler. All
other characters are passed through to the listing file, but are
otherwise ignored.
.P
The source file is divided into lines by newline character(s).
The internal buffers of the cross-assembler will
accommodate lines of up to 255 characters which should be more
than ample for almost any job. If you must use longer lines,
change the constant MAXLINE in file z80a.h and recompile the
cross-assembler. Otherwise, you will overflow the buffers, and
the program will mysteriously crash.
.P
Each source line is made up of three fields: the label
field, the opcode field, and the argument field.
The label field
is optional, but if it is present, it must begin in column 1.
The opcode field is optional, but if it is present, it must not
begin in column 1.
If both a label and an opcode are present,
one or more spaces and/or TAB characters must separate the two.
If the opcode requires arguments, they are placed in the argument
field which is separated from the opcode field by one or more
spaces and/or TAB characters.
Multiple arguments are separated by semicolons.
Finally, an optional comment can
be added to the end of the line. This comment can begin with an
optional
asterisk which signals the assembler to pass the rest of the
line to the listing and otherwise ignore it.
The assembler ignores any text after the argument field, for this
reason arguments must not contain any spaces.
Thus, the source line looks like this:
.DS I
{label}{ opcode{ arguments}}{{*}commentary}
.DE
where the { } indicates that the specified item is optional.
.DS I
Some examples are in order:
.DE
.DF I
column 1
|
v
GRONK JP NC; LOOP This line has everything.
INC C This line has no label.
BEEP This line has no opcode.
* This line has no label and no opcode.
* The previous line has nothing at all.
END This line has no argument.
.DE
.H 2 Labels
.P
A label is any sequence of alphabetic or numeric characters
starting with an alphabetic. The legal alphabetics are:
.DS I
! $ % & , . : ? [ \\\ ] ^ _ ` { | } ~ A-Z a-z
.DE
.P
The numeric characters are the digits 0-9.
Note that "A" is not the same as "a" in a label.
This is an enhancement from the mini-computer version which
accepted only upper case labels.
This can explain mysterious U (undefined label) errors occurring
when a label appears to be defined.
.P
A label is permitted on any line except a line where the
opcode is LIST, ULIST, NCODE, CODE, TTL, PAG, PAGT, SKP, TYP,
IF, ELS, or ENF.
The label is assigned the value of
the assembly program counter before any of the rest of the line
is processed except when the opcode is EQU, ORG, or SET.
.P
Labels can have the same name as opcodes, but they cannot
have the same name as operators or registers. The reserved
(operator and register) names are:
.DS
* A AF AND B BC
C D DE EQ GE GT
H HIGH HL IX IY L
LE LT LOW M MOD NC
NE NOT NZ OR P PE
PO SHL SHR SP XOR Z
.DE
.P
Labels may be pin-addressed by the use of an "@" as a prefix to the label.
Pin-address labels are referenced in the code by the opposite side of the
bytes than they normally would. For example this DC strings' label
points to the right hand address of the string[B:
.DS I
LABEL DC "this is a normal string"
.DE
.P
If you then generate a pin-addressed version of the
same string the label refers to the left hand address of the string:
.DS I
@LABEL DC "this is a normal string"
.DE
.P
It is neccessary to include pin-addressing in this assembler
to remain compatable with existing source files written with
the mini-computer version.
The sense of byte addresses when referenced without pin-addressing
is reversed from what one would expect in many pseudo ops such
as DC and DAC.
.P
If a label is used in an expression before it is assigned a
value, the label is said to be "forward-referenced." For
example:
.DS
L1 EQU L2+1 L2 is forward-referenced here.
L2
L3 EQU L2+1 L2 is not forward-referenced here.
.DE
.P
Note no space between operands or operators is allowed.
.H 2 "Numeric Constants"
.P
Numeric constants can be formed in two ways; the mini-computer version,
or by the Intel convention.
The Intel convention was not part of the original mini-computer language,
but has been added as an enhancement.
.P
The original standard used only decimal or hexadecimal numbers in the
style of Motorola.
Decimal numbers are formed by using the digits 0-9.
Hexadecimal numbers are formed by using a dollar sign ($) followed
by one or more hexadecimal digits (0-9, A-F).
The hex digits a-f are converted to upper case by the assembler.
Also added as an enhancement was the (%) Motorola style prefix
for binary numbers. In this case only 0 and 1 are allowed
as digits.
.P
A numeric constant formed according to the Intel convention
starts with a numeric character
(0-9), continues with zero or more digits (0-9, A-F), and ends
with an option